using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Daniel.Core.Models.Mapping
{
    public class GiftCardMap : EntityTypeConfiguration<GiftCard>
    {
        public GiftCardMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            // Table & Column Mappings
            this.ToTable("GiftCard");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.PurchasedWithOrderItemId).HasColumnName("PurchasedWithOrderItemId");
            this.Property(t => t.GiftCardTypeId).HasColumnName("GiftCardTypeId");
            this.Property(t => t.Amount).HasColumnName("Amount");
            this.Property(t => t.IsGiftCardActivated).HasColumnName("IsGiftCardActivated");
            this.Property(t => t.GiftCardCouponCode).HasColumnName("GiftCardCouponCode");
            this.Property(t => t.RecipientName).HasColumnName("RecipientName");
            this.Property(t => t.RecipientEmail).HasColumnName("RecipientEmail");
            this.Property(t => t.SenderName).HasColumnName("SenderName");
            this.Property(t => t.SenderEmail).HasColumnName("SenderEmail");
            this.Property(t => t.Message).HasColumnName("Message");
            this.Property(t => t.IsRecipientNotified).HasColumnName("IsRecipientNotified");
            this.Property(t => t.CreatedOnUtc).HasColumnName("CreatedOnUtc");

            // Relationships
            this.HasOptional(t => t.OrderItem)
                .WithMany(t => t.GiftCards)
                .HasForeignKey(d => d.PurchasedWithOrderItemId);

        }
    }
}
